package com.slipper.system.common;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import com.slipper.system.api.employee.bo.EmployeeBO;
import com.slipper.system.api.organization.bo.OrganizationBO;

public class UserDetail implements Serializable {
    private static final long serialVersionUID = -1L;

    private String sessionId;
    private String clientFlag;
    private Date loginTime;
    private boolean superAdmin;
    private EmployeeBO employee; // 员工信息
    private Set<String> permitSet; // 权限

    private String unitId;
    private String unitName;
    private String orgId;
    private String orgName;
    private String orgCode;
    private String orgType;

    public boolean isSuperAdmin() {
        return superAdmin;
    }

    public String getEmployeeId() {
        return this.employee.getId();
    }

    public String getUnitId() {
        return unitId;
    }

    public void setUnitId(String unitId) {
        this.unitId = unitId;
    }

    public String getUnitName() {
        return unitName;
    }

    public void setUnitName(String unitName) {
        this.unitName = unitName;
    }

    public String getOrgId() {
        return this.orgId;
    }

    public Set<String> getPermitSet() {
        return permitSet;
    }

    public EmployeeBO getEmployee() {
        return employee;
    }

    public void setEmployee(EmployeeBO employee) {
        this.employee = employee;
    }

    public void setOrganization(OrganizationBO organization) {
        this.orgId = organization.getId();
        this.orgName = organization.getShortName();
        this.orgType = organization.getType();
    }

    public void setPermitSet(Set<String> permitSet) {
        this.permitSet = permitSet;
    }

    public String getSessionId() {
        return sessionId;
    }

    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }

    public Date getLoginTime() {
        return loginTime;
    }

    public void setLoginTime(Date loginTime) {
        this.loginTime = loginTime;
    }

    public String getClientFlag() {
        return clientFlag;
    }

    public void setClientFlag(String clientFlag) {
        this.clientFlag = clientFlag;
    }

    public boolean hasPermit(String actionUrl) {
        return this.getPermitSet() != null && this.getPermitSet().contains(actionUrl);
    }

    public void setOrgId(String orgId) {
        this.orgId = orgId;
    }

    public String getOrgName() {
        return orgName;
    }

    public void setOrgName(String orgName) {
        this.orgName = orgName;
    }

    public String getOrgCode() {
        return orgCode;
    }

    public void setOrgCode(String orgCode) {
        this.orgCode = orgCode;
    }

    public String getOrgType() {
        return orgType;
    }

    public void setOrgType(String orgType) {
        this.orgType = orgType;
    }

    public void setSuperAdmin(boolean superAdmin) {
        this.superAdmin = superAdmin;
    }
}
